﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SsTool
{
    /// <summary>
    /// Interaction logic for ConnectWindow.xaml
    /// </summary>
    public partial class ConnectWindow : Window
    {
        public ConnectWindow()
        {
            InitializeComponent();
        }

        private void _ctlBtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(_ctlEditServer.Text.Trim())
                || string.IsNullOrEmpty(_ctlEditDb.Text.Trim())
                || string.IsNullOrEmpty(_ctlEditUid.Text.Trim())
                || string.IsNullOrEmpty(_ctlEditPwd.Password.Trim()))
            {
                return;
            }

            if (App.Init(_ctlEditServer.Text.Trim(),
                _ctlEditDb.Text.Trim(),
                _ctlEditUid.Text.Trim(),
                _ctlEditPwd.Password.Trim()))
            {
                DialogResult = true;
            }
            else
            {
                MessageBox.Show("初始化失败!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

        private void _ctlBtnCancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
